home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8404.arc / REGCNV05.ASM < prev    next >
Assembly Source File  |  1986-01-18  |  2KB  |  94 lines

  1.     title    REGCNV05 -- Convert contents of AX to hex characters.
  2.     page    60,120
  3.  
  4.     name    REGCNV05    ; module
  5.  
  6. comment |         Module Specifications
  7.  
  8. Copyright: None.
  9.  
  10. Environment: IBM PC, tested under DOS 2.0.
  11.  
  12. Segmentation: Program segment CODE, public, byte aligned, class ''.
  13.  
  14. Public symbols and external references: See Symbols section of listing.
  15.  
  16. Link requirements: None, standalone subroutine.
  17.  
  18. Program derived from: REGCNV04.
  19.  
  20. Original code by: Bob Smith and Tom Puckett, October 1983.
  21.  
  22. Modifications by: Bob Smith and Tom Puckett, October 1983.
  23.           Sequence of four ROL DX,1 replaced by single ROL DX,CL.
  24.  
  25.  
  26.             Procedure Specifications
  27.  
  28. Public Procedure REGCNV05 -- Convert value in AX to ASCII characters.
  29.  
  30.     This is a subroutine to format and place in storage four ASCII
  31.     characters giving a hexadecimal representation of the value
  32.     passed in AX.
  33.  
  34.     Assumptions: None.
  35.  
  36.     Linkage: Near call and return.
  37.  
  38.     Arguments: AX contains value to be formatted.
  39.            ES:DI point to destination where result is to be placed.
  40.  
  41.     Effects: None.
  42.  
  43.     Results: Flags and AX destroyed.
  44.          DI incremented by four.
  45.          Four hexadecimal digits formatted as ASCII characters
  46.             placed at ES:DI.
  47.  
  48.     Return conditions: None.
  49.  
  50.     Limitations: None.
  51.  
  52. |
  53.     page
  54.  
  55. code    segment    public byte
  56.     assume    cs:code
  57.  
  58. hextable db    '0123456789ABCDEF'    ; for XLAT below
  59.  
  60.  
  61.  
  62.     public    REGCNV05
  63. REGCNV05    proc    near    ; see specifications at head of listing
  64.  
  65.     push    bx        ; preserve
  66.     push    cx
  67.     push    dx
  68.  
  69.     cld            ; for STOSB below
  70.     mov    cl,4        ; for ROL below
  71.     mov    dx,ax        ; value to be formatted
  72.     mov    ah,4        ; four hex digits to convert
  73.     mov    bx,offset hextable    ; translate table
  74.  
  75. digitloop:
  76.     rol    dx,cl        ; the fast way
  77.     mov    al,dl
  78.     and    al,0fh        ; mask off what's not wanted
  79.     xlat    hextable    ; convert AL to ASCII
  80.     stosb            ; stuff AL at ES:DI, update DI
  81.     dec    ah        ; loop counter
  82.     jnz    digitloop
  83.  
  84.     pop    dx        ; restore
  85.     pop    cx
  86.     pop    bx
  87.     ret
  88.  
  89. REGCNV05 endp
  90.  
  91. code    ends        ; end code segment
  92.  
  93.      end        ; end module
  94.